---
category: Array
created: '2020-04-19'
title: Get the sum of an array of numbers
updated: '2021-10-13'
---

**JavaScript version**

```js sum.js
const sum = (arr) => arr.reduce((a, b) => a + b, 0);
```

**TypeScript version**

```ts sum.ts
const sum = (arr: number[]): number => arr.reduce((a, b) => a + b, 0);
```
